a = list(map(int, input().split()))


def ok(a, i, j):
    if j > i:
        for k in range(i, j):
            if a[k] == a[j]:
                return False
    return True


def dfs(a, n, i):
    if i == n:
        print(a)
    else:
        for j in range(i, n):
            if ok(a, i, j):
                a[i], a[j] = a[j], a[i]
                dfs(a, n, i + 1)
                a[i], a[j] = a[j], a[i]


n = len(a)
dfs(a, n, 0)
